const Router = require("koa-router");
const { verifyAuth } = require("../middleware/auth.middleware");
const {
  create,
  resultAllCapital,
  updateCapitalController,
  deleteCapital
} = require("../controller/capital.controller");
const { checkValue, getAllCapital } = require("../middleware/capital.middleware");
const capitalRouter = new Router({ prefix: "/capital" });

/**
 *  @route POST /capital/add
 *  @desc 添加资金管理记率
 *  @access Private
 * */
capitalRouter.post("/add", verifyAuth, checkValue, create);
/**
 *  @route GET /capital
 *  @desc 获取所有资金管理记率
 *  @access Private
 * */
capitalRouter.get("/", verifyAuth, getAllCapital, resultAllCapital);
/**
 *  @route GET /capital/:id
 *  @desc 获取单个资金管理记率
 *  @access Private
 * */
capitalRouter.get("/:id", verifyAuth, getAllCapital, resultAllCapital);

/**
 *  @route patch /capital/:id
 *  @desc 获取单个资金管理记率
 *  @access Private
 * */
capitalRouter.patch("/:id", verifyAuth, checkValue, getAllCapital, updateCapitalController);

/**
 *  @route delete /capital/:id
 *  @desc 获取单个资金管理记率
 *  @access Private
 * */
capitalRouter.delete("/:id", verifyAuth, getAllCapital, deleteCapital);
module.exports = capitalRouter;
